package cn.kilo.domain.service.order.impl;

import cn.kilo.domain.model.order.entity.OrderEntity;
import cn.kilo.domain.model.order.entity.StaffEntity;
import cn.kilo.domain.model.order.vo.OrderStatusVO;
import cn.kilo.domain.service.order.AbstractStaffStrategyChain;
import cn.kilo.domain.service.order.factory.DefaultFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author kilok
 */
@Slf4j
@Component("over")
public class OverStrategy extends AbstractStaffStrategyChain {
    @Override
    public List<OrderStatusVO> doJob(OrderEntity order) {
        OrderStatusVO orderStatusVO = repository.getOrderInfoAndDelete(OrderEntity.builder().orderId(order.getOrderId()).build());
        order.setStatus(DefaultFactory.Status.CONFIRM.getInfo());
        order.setOrderId(orderStatusVO.getOrderId());
        order.setStatus(orderStatusVO.getStatus());
        order.setEndTime(order.getEndTime());
        repository.updateOrderStatus(order);
        List<OrderStatusVO> list=new ArrayList<>();
        list.add(orderStatusVO);
        return list;
    }

    @Override
    public DefaultFactory.Role getRole() {
        return DefaultFactory.Role.OVER;
    }

    @Override
    public Map<String, Integer> getLeftStaff(OrderEntity order) {
        return null;
    }

    @Override
    public boolean beStaff(StaffEntity staffEntity) {
        return false;
    }
}
